package com.itcast.generic;

import java.util.Objects;

// 定义接口，print 方法可以传入不同的数据类型
interface PrintInfo<T> {
    public void print(T obj);
}


class PrintString implements PrintInfo<String> {
    @Override
    public void print(String obj) {
        System.out.println(obj);
    }
}

class PrintDouble implements PrintInfo<Double> {
    @Override
    public void print(Double obj) {
        System.out.println(obj + "");
    }
}

class Test {
    public static void main(String[] args) {
        // 字符串实现
        new PrintString() {}.print("这里是字符串实现");

        // 这里是浮点数实现
        PrintDouble printDouble = new PrintDouble() {};
        printDouble.print(1.234);
    }
}
